<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<div style="padding:10px 10px 10px 10px">
    <form id="content" method="post">
        <table cellpadding="5">
            <tr>
                <td>车队名称:</td>
                <td><input name="teamName" class="easyui-textbox"
                           data-options="method:'post',
                                  height:20"
                           style="width: 200px"/></td>
            </tr>
            <tr>
                <td>负责人:</td>
                <td><input name="admin"
                           class="easyui-textbox"
                           data-options="
                                     method:'post',
                                     height:20,
                                     required:true"
                           style="width: 200px"/></td>
            </tr>
            <tr>
                <td>负责人电话:</td>
                <td><input name="phone"
                           class="easyui-textbox"
                           data-options="
                                     method:'post',
                                     height:20,
                                     required:true"
                           style="width: 200px"/></td>
            </tr>
        </table>
    </form>
    <div style="padding:5px">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           onclick="submitForm()">提交</a> <a href="javascript:void(0)"
                                            class="easyui-linkbutton" onclick="clearForm()">重置</a>
    </div>
</div>
<script type="text/javascript">
    function submitForm() {
        if (!$('#content').form('validate')) {
            $.messager.alert('提示', '表单还未填写完成!');
            return;
        }
        $.post("${pageContext.request.contextPath}/busTeam/add", $("#content").serialize(), function (data) {
            if (data.code == 200) {
                $.messager.alert('提示', '新增车队成功!');
                $('#teamAdd').window('close');
                $("#teamList").datagrid('reload');
                clearForm();
            } else {
                $.messager.alert('提示', '新增车队失败!');
            }
        }, "json");
    }

    function clearForm() {
        $('#content').form('reset');
    }

</script>